Imports System.Data.SqlClient
Public Class cls_proveedorarticulo_

    Implements ICloneable

#Region "Variables ..."
    Private int_idproveedorarticulo As Integer = 0
    Private int_idproveedor As Integer = 0
    Private int_idarticulo As Integer = 0
    Private int_idmoneda As Integer = 0
    Private str_codigo As String = ""
    Private str_descripcion As String = ""
    Private dte_fecha As DateTime = New System.DateTime(Now.Year, 1, 1)
    Private dbl_valor As Decimal = 0
    Private str_notas As String = ""
    Private int_idregistro As Integer = 0
    Private int_idunidaddetalle As Integer = 0

    Private obj_proveedor As cls_proveedor_
    Private obj_articulo As cls_articulo_
    Private obj_moneda As cls_moneda_
    Private obj_registro As cls_registro_
    Private obj_unidaddetalle As cls_unidaddetalle_

    Private col_Items As Collections.Generic.List(Of cls_proveedorarticulo_) = Nothing
#End Region

    Public Overrides Function ToString() As String
        Return articulo.ToString & " " & valor & " " & moneda.simbolo
    End Function

#Region "Propiedades ..."
    ReadOnly Property This
        Get
            Return Me
        End Get
    End Property
    ReadOnly Property ThisDescripcion As String
        Get
            Return Me.ToString
        End Get
    End Property
    ReadOnly Property pKey
        Get
            Return idproveedorarticulo
        End Get
    End Property
    Property idproveedorarticulo() As Integer
        Get
            idproveedorarticulo = int_idproveedorarticulo
        End Get
        Set(ByVal value As Integer)
            int_idproveedorarticulo = value
        End Set
    End Property
    Property idproveedor() As Integer
        Get
            idproveedor = int_idproveedor
        End Get
        Set(ByVal value As Integer)
            int_idproveedor = value
        End Set
    End Property
    Property idarticulo() As Integer
        Get
            idarticulo = int_idarticulo
        End Get
        Set(ByVal value As Integer)
            int_idarticulo = value
        End Set
    End Property
    Property idmoneda() As Integer
        Get
            idmoneda = int_idmoneda
        End Get
        Set(ByVal value As Integer)
            int_idmoneda = value
        End Set
    End Property
    Property codigo() As String
        Get
            codigo = str_codigo
        End Get
        Set(ByVal value As String)
            str_codigo = value
        End Set
    End Property
    Property descripcion() As String
        Get
            descripcion = str_descripcion
        End Get
        Set(ByVal value As String)
            str_descripcion = value
        End Set
    End Property
    Property fecha() As DateTime
        Get
            fecha = dte_fecha
        End Get
        Set(ByVal value As DateTime)
            dte_fecha = value
        End Set
    End Property
    Property valor() As Decimal
        Get
            valor = dbl_valor
        End Get
        Set(ByVal value As Decimal)
            dbl_valor = value
        End Set
    End Property
    Property notas() As String
        Get
            notas = str_notas
        End Get
        Set(ByVal value As String)
            str_notas = value
        End Set
    End Property
    Property idregistro() As Integer
        Get
            idregistro = int_idregistro
        End Get
        Set(ByVal value As Integer)
            int_idregistro = value
        End Set
    End Property
    Property idunidaddetalle As Integer
        Get
            idunidaddetalle = int_idunidaddetalle
        End Get
        Set(ByVal value As Integer)
            int_idunidaddetalle = value
        End Set
    End Property
    Property registro() As cls_registro_
        Get
            If IsNothing(obj_registro) Then
                obj_registro = New cls_registro_
                If Not obj_registro.Buscar(idregistro) Then
                    obj_registro = Nothing
                End If
            End If
            registro = obj_registro
        End Get
        Set(ByVal value As cls_registro_)
            obj_registro = value
        End Set
    End Property
    Property unidaddetalle() As cls_unidaddetalle_
        Get
            If IsNothing(obj_unidaddetalle) Then
                obj_unidaddetalle = New cls_unidaddetalle_
                If Not obj_unidaddetalle.Buscar(idunidaddetalle) Then
                    obj_unidaddetalle = Nothing
                End If
            End If
            unidaddetalle = obj_unidaddetalle
        End Get
        Set(ByVal value As cls_unidaddetalle_)
            obj_unidaddetalle = value
        End Set
    End Property
    Property moneda() As cls_moneda_
        Get
            If IsNothing(obj_moneda) Then
                obj_moneda = New cls_moneda_
                If Not obj_moneda.Buscar(idmoneda) Then
                    obj_moneda = Nothing
                End If
            End If
            moneda = obj_moneda
        End Get
        Set(ByVal value As cls_moneda_)
            obj_moneda = value
        End Set
    End Property
    Property articulo() As cls_articulo_
        Get
            If IsNothing(obj_articulo) Then
                obj_articulo = New cls_articulo_
                If Not obj_articulo.Buscar(idarticulo) Then
                    obj_articulo = Nothing
                End If
            End If
            articulo = obj_articulo
        End Get
        Set(ByVal value As cls_articulo_)
            obj_articulo = value
        End Set
    End Property
    Property proveedor() As cls_proveedor_
        Get
            If IsNothing(obj_proveedor) Then
                obj_proveedor = New cls_proveedor_
                If Not obj_proveedor.Buscar(idproveedor) Then
                    obj_proveedor = Nothing
                End If
            End If
            proveedor = obj_proveedor
        End Get
        Set(ByVal value As cls_proveedor_)
            obj_proveedor = value
        End Set
    End Property

    Property Items() As Collections.Generic.List(Of cls_proveedorarticulo_)
        Get
            Items = col_Items
        End Get
        Set(ByVal value As Collections.Generic.List(Of cls_proveedorarticulo_))
            col_Items = value
        End Set
    End Property
#End Region

    Private Sub CargarColeccion(ByVal obj_Reader As SqlDataReader)
        col_Items = New Collections.Generic.List(Of cls_proveedorarticulo_)
        While obj_Reader.Read()
            Dim Elemento As New cls_proveedorarticulo_
            Elemento.int_idproveedorarticulo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedorarticulo")))

            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor"))) = False Then
                Elemento.int_idproveedor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idarticulo"))) = False Then
                Elemento.int_idarticulo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idarticulo")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idmoneda"))) = False Then
                Elemento.int_idmoneda = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idmoneda")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo"))) = False Then
                Elemento.str_codigo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("descripcion"))) = False Then
                Elemento.str_descripcion = (obj_Reader.GetValue(obj_Reader.GetOrdinal("descripcion")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("fecha"))) = False Then
                Elemento.dte_fecha = (obj_Reader.GetValue(obj_Reader.GetOrdinal("fecha")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("valor"))) = False Then
                Elemento.dbl_valor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("valor")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("notas"))) = False Then
                Elemento.str_notas = (obj_Reader.GetValue(obj_Reader.GetOrdinal("notas")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro"))) = False Then
                Elemento.int_idregistro = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idunidaddetalle"))) = False Then
                Elemento.int_idunidaddetalle = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idunidaddetalle")))
            End If
            col_Items.Add(Elemento)
        End While
    End Sub

    Private Sub CargarVariables(ByVal obj_Reader As SqlDataReader)
        obj_Reader.Read()
        int_idproveedorarticulo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedorarticulo")))

        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor"))) = False Then
            int_idproveedor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idarticulo"))) = False Then
            int_idarticulo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idarticulo")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idmoneda"))) = False Then
            int_idmoneda = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idmoneda")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo"))) = False Then
            str_codigo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("descripcion"))) = False Then
            str_descripcion = (obj_Reader.GetValue(obj_Reader.GetOrdinal("descripcion")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("fecha"))) = False Then
            dte_fecha = (obj_Reader.GetValue(obj_Reader.GetOrdinal("fecha")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("valor"))) = False Then
            dbl_valor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("valor")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("notas"))) = False Then
            str_notas = (obj_Reader.GetValue(obj_Reader.GetOrdinal("notas")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro"))) = False Then
            int_idregistro = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idunidaddetalle"))) = False Then
            int_idunidaddetalle = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idunidaddetalle")))
        End If
    End Sub

    Public Function Nuevo(Optional ByVal ObtenerID As Boolean = False) As Boolean
        Nuevo = False
        Dim obj_Conexion As New cls_Conexion
        Try

            'Creacion de registro----------------------------------------------------
            If IsNothing(obj_registro) Then
                registro = New cls_registro_
                registro.fechacreado = Now
                registro.idusuariocreado = UsuarioLOG.idusuario
                registro.fechamodificado = Now
                registro.idusuariomodificado = UsuarioLOG.idusuario
                registro.idregistroestado = 1
                registro.idusuarioregistroestado = UsuarioLOG.idusuario
                registro.Nuevo(True)
                idregistro = obj_registro.idregistro
            End If
            '------------------------------------------------------------------------

            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__Nuevo"
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
                .Parameters.Add("@idarticulo", SqlDbType.Int).Value = int_idarticulo
                .Parameters.Add("@idmoneda", SqlDbType.Int).Value = int_idmoneda
                .Parameters.Add("@codigo", SqlDbType.NVarChar).Value = str_codigo
                .Parameters.Add("@descripcion", SqlDbType.NVarChar).Value = str_descripcion
                .Parameters.Add("@fecha", SqlDbType.DateTime).Value = dte_fecha
                .Parameters.Add("@valor", SqlDbType.Decimal).Value = dbl_valor
                .Parameters.Add("@notas", SqlDbType.NVarChar).Value = str_notas
                .Parameters.Add("@idregistro", SqlDbType.Int).Value = int_idregistro
                .Parameters.Add("@idunidaddetalle", SqlDbType.Int).Value = int_idunidaddetalle
                .ExecuteNonQuery()
            End With
            Nuevo = True
            If ObtenerID Then
                CargarUltimo()
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al Crear el registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Function

    Public Sub Modificar()
        Dim obj_Conexion As New cls_Conexion
        Try

            'Modificacion de registro------------------------------------------------
            registro.fechamodificado = Now : registro.idusuariomodificado = UsuarioLOG.idusuario
            registro.Modificar()
            '------------------------------------------------------------------------

            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__Modificar"
                .Parameters.Add("@idproveedorarticulo", SqlDbType.Int).Value = int_idproveedorarticulo
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
                .Parameters.Add("@idarticulo", SqlDbType.Int).Value = int_idarticulo
                .Parameters.Add("@idmoneda", SqlDbType.Int).Value = int_idmoneda
                .Parameters.Add("@codigo", SqlDbType.NVarChar).Value = str_codigo
                .Parameters.Add("@descripcion", SqlDbType.NVarChar).Value = str_descripcion
                .Parameters.Add("@fecha", SqlDbType.DateTime).Value = dte_fecha
                .Parameters.Add("@valor", SqlDbType.Decimal).Value = dbl_valor
                .Parameters.Add("@notas", SqlDbType.NVarChar).Value = str_notas
                .Parameters.Add("@idregistro", SqlDbType.Int).Value = int_idregistro
                .Parameters.Add("@idunidaddetalle", SqlDbType.Int).Value = int_idunidaddetalle
                .ExecuteNonQuery()
            End With
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al Modificar el registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Sub

    Public Sub Eliminar(ByVal idproveedorarticulo As Integer)
        Dim obj_Conexion As New cls_Conexion
        Try
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__Eliminar"
                .Parameters.Add("@idproveedorarticulo", SqlDbType.Int).Value = idproveedorarticulo
                .ExecuteNonQuery()
            End With
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al Eliminar el registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Sub

    Public Function Buscar(ByVal idproveedorarticulo As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            Buscar = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__Buscar"
                .Parameters.Add("@idproveedorarticulo", SqlDbType.Int).Value = idproveedorarticulo
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarVariables(obj_Reader)
                Buscar = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al Buscar el registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Function BuscarUltimoXidarticuloXidproveedor(ByVal int_idproveedor As Integer, ByVal int_idarticulo As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            BuscarUltimoXidarticuloXidproveedor = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__BuscarUltimoXidarticuloXidproveedor"
                .Parameters.Add("@idarticulo", SqlDbType.Int).Value = int_idarticulo
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarVariables(obj_Reader)
                BuscarUltimoXidarticuloXidproveedor = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al BuscarXidarticuloXidproveedor el registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Sub CargarUltimo()
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarUltimo"
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarVariables(obj_Reader)
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarUltimo registro de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Sub

    Public Function CargarTodos() As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarTodos = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarTodos"
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarTodos = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarTodos los registros de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj_proveedorarticulo_Clon As New cls_proveedorarticulo_
        obj_proveedorarticulo_Clon.int_idproveedorarticulo = Me.int_idproveedorarticulo
        obj_proveedorarticulo_Clon.int_idproveedor = Me.int_idproveedor
        obj_proveedorarticulo_Clon.int_idarticulo = Me.int_idarticulo
        obj_proveedorarticulo_Clon.int_idmoneda = Me.int_idmoneda
        obj_proveedorarticulo_Clon.str_codigo = Me.str_codigo
        obj_proveedorarticulo_Clon.str_descripcion = Me.str_descripcion
        obj_proveedorarticulo_Clon.dte_fecha = Me.dte_fecha
        obj_proveedorarticulo_Clon.dbl_valor = Me.dbl_valor
        obj_proveedorarticulo_Clon.str_notas = Me.str_notas
        obj_proveedorarticulo_Clon.int_idregistro = Me.int_idregistro
        obj_proveedorarticulo_Clon.int_idunidaddetalle = Me.int_idunidaddetalle
        obj_proveedorarticulo_Clon.col_Items = Me.col_Items
        Return obj_proveedorarticulo_Clon
    End Function

    Function CargarXidproveedor(ByVal int_idproveedor As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarXidproveedor = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarXidproveedor"
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarXidproveedor = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarXidproveedor los registros de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Function CargarTodosXidproveedor(ByVal int_idproveedor As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarTodosXidproveedor = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarTodosXidproveedor"
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarTodosXidproveedor = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarXidproveedor los registros de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Function CargarTodosXidproveedorXidarticulo(ByVal int_idproveedor As Integer, ByVal int_idarticulo As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarTodosXidproveedorXidarticulo = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarTodosXidproveedorXidarticulo"
                .Parameters.Add("@idproveedor", SqlDbType.Int).Value = int_idproveedor
                .Parameters.Add("@idarticulo", SqlDbType.Int).Value = int_idarticulo
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarTodosXidproveedorXidarticulo = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarTodosXidproveedorXidarticulo los registros de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Function CargarXidarticulo(ByVal int_idarticulo As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarXidarticulo = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "proveedorarticulo__CargarXidarticulo"
                .Parameters.Add("@idarticulo", SqlDbType.Int).Value = int_idarticulo
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarXidarticulo = True
            End If
        Catch ex As SqlClient.SqlException
            Throw New Exception("Error al CargarTodosXidproveedorXidarticulo los registros de proveedorarticulo_." & Chr(13) & _
           "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
           "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
           "Descripción: " & ex.Message)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

End Class
